import React, { Component } from 'react'
// 7. 导入 store
import store from './store/index'

export default class App extends Component {
  render() {

    // console.log(store.getState().count);
    return (
      <div>
        App
        {/* 8. 在组件中通过 store.getState() 获取全局状态 */}
        <h1>{store.getState().count}</h1>

        <button onClick={()=>{
          store.dispatch({type: 'add'})
        }}>加 1</button>

        <button onClick={()=>{
          store.dispatch({type: 'reduce'})
        }}>减 1</button>

        <button onClick={()=>{
          store.dispatch({type: 'addNum', payload: 10})
        }}>加 10</button>


        <button onClick={()=>{
          store.dispatch({type: 'reduceNum', payload: 10})
        }}>减 10</button>

      </div>
    )
  }
}
